import cv2

path = r"F:\study\python\study_LIjun\media"
cap = cv2.VideoCapture(0)
fps = cap.get(cv2.CAP_PROP_FPS)
size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)),
        int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
video_writer = cv2.VideoWriter(path + "/my.avi",
                               cv2.VideoWriter_fourcc('X', 'V', 'I', 'D'),
                               fps, size)
while 1:
    ret, frame = cap.read()
    frame = cv2.flip(frame, 1)
    cv2.imshow("capture", frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()
